package com.stylefeng.guns.config;

import org.springframework.context.annotation.Configuration;

/**
 * Created by qingynzhang on 2018/4/2.
 * 根据不同租户集成不同单点系统
 */
@Configuration
public class AuthConfiguration {
	/*
    @Configuration
    @Import({SSOResource.class, RedisSessionConfig.class})
    static class WblAuthAutoConfiguration {
    	@Bean(name="passportClientFilterBean;filterSSOBean")
        public FilterRegistrationBean passportClientFilterBean() {
    		String tenantId = AdminConstant.DEFAULT_SITEID;
    		if(!"002".equals(tenantId)){
    			 FilterRegistrationBean registrationBean = new FilterRegistrationBean();
    	            PassportClientFilter passportClientFilter = new PassportClientFilter();
    	            registrationBean.setFilter(passportClientFilter);
    	            List<String> urlPatterns = new ArrayList<String>();
    	            //设置需要授权url
    	            urlPatterns.add("/clmRoom/*");
    	    		urlPatterns.add("/teacher/*");
    	    		urlPatterns.add("/column/*");
    	    		
    	    		registrationBean.setUrlPatterns(urlPatterns);
    	    		registrationBean.setOrder(3);
    	    		//排除指定目录，排除指定接口见文档
    	    		registrationBean.addInitParameter("excludedPagesPath", "/static/;/js/;/img/;/plugins/;/public/liveApi/;/public/liveAdminApi/;/public/;/s_live/a/;/private/clm/room/admin_look/;/s_live/c/;/private/clm/courseware/course_look/");
    	    		//registrationBean.addInitParameter("excludedServerPath",PropertiesUtils.getLiveAppUrl());
    	    		
    	            return registrationBean;
    		}else{
    			FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new LoginFilter());

         		List<String> urlPatterns = new ArrayList<String>();
         		urlPatterns.add("/clmRoom/*");
        		urlPatterns.add("/teacher/*");
        		urlPatterns.add("/column/*");
         		filterRegistrationBean.setUrlPatterns(urlPatterns);
         		filterRegistrationBean.setOrder(2);
         		//排除指定目录，排除指定接口见文档
         		filterRegistrationBean.addInitParameter("excludedPagesPath", "/static/;/js/;/img/;/plugins/;/public/liveApi/;/public/liveAdminApi/;/public/;/s_live/a/;/private/clm/room/admin_look/;/s_live/c/;/private/clm/courseware/course_look/");
         		//排除指定域名
         		//filterRegistrationBean.addInitParameter("excludedPagesDomain", PropertiesUtils.getLiveAppUrl());
         		return filterRegistrationBean;
    		}
           
        }
    	
    	@Bean
        public ServletListenerRegistrationBean MySessionListenerRegistrationBean() {
            ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
            servletListenerRegistrationBean.setListener(new MySessionListener());
            return servletListenerRegistrationBean;
        }

        @Bean
        public FilterRegistrationBean passportLogOutFilterBean() {
            FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new PassportLogOutFilter());

            List<String> urlPatterns = new ArrayList<String>();
            urlPatterns.add("/*");
            filterRegistrationBean.setUrlPatterns(urlPatterns);
            filterRegistrationBean.setOrder(1);
            return filterRegistrationBean;
        }

        @Bean
        public FilterRegistrationBean filterProxy() {
            DelegatingFilterProxy springSessionRepositoryFilter = new DelegatingFilterProxy();
//            springSessionRepositoryFilter.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher");
            FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
            filterRegistrationBean.setFilter(springSessionRepositoryFilter);
            Map<String,String> map = new HashMap<String,String>();
            map.put("targetBeanName","springSessionRepositoryFilter");
            map.put("targetFilterLifecycle","true");
            filterRegistrationBean.setInitParameters(map);
            List<String> urlPatterns = new ArrayList<String>();
            urlPatterns.add("/*");
            filterRegistrationBean.setUrlPatterns(urlPatterns);
            filterRegistrationBean.setOrder(2);
            return filterRegistrationBean;
        }

    }*/
    

}
